﻿package classes
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.events.MouseEvent;
	import classes.events.MenuItemEvent;
	/**
	 * ...
	 * @author ...
	 */
	public class GameMenuItem extends MovieClip 
	{
		private var menuItemText:TextField = new TextField();
		
		private function init():void 
		{
			this.useHandCursor = true;
			this.mouseChildren = false;
			this.buttonMode = true;
		}
		
		public function GameMenuItem(text:String):void
		{
			this.menuItemText.text = text;
			this.addChild(this.menuItemText);
			//this.addEventListener(MouseEvent.CLICK, handleClick);
			this.init();
		}
		
		public function setText(newText:String):void 
		{
			this.menuItemText.text = newText;
		}
		
		public function getText():String
		{
			return this.menuItemText.text;
		}
		
		public function removeMenuItemListener():void
		{
			this.removeEventListener(MouseEvent.CLICK, handleClick);
		}
		
		private function handleClick(e:MouseEvent):void 
		{
			dispatchEvent(new MenuItemEvent(MenuItemEvent.MENU_CLICK_EVENT,this.menuItemText.text));
		}
	}
	
}